<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>增加</title>
</head>

<body>
    <table>
        <h3>添加博客或者修改</h3>
    <tr>
        <td>标题</td>
        <td><input type="text" id="title"></td>
    </tr>
    <tr>
        <td>摘要</td>
        <td><input type="text" id="abstract"></td>
    </tr>
    <tr>
        <td>内容</td>
        <td><input type="text" id="content"></td>
    </tr>
    <tr>
        <td>分类</td>
        <td><input type="text" id="classify"></td>
    </tr>
    <tr>
        <td>作者</td>
        <td><input type="text" id="autor"></td>
    </tr>


    <input type="button" value="保存" onclick="addArr()">
    <input type="button" value="取消" onclick="cancel()">
    </table>
    <script src="./js/jquery-3.6.0.min.js"></script>
    <script src="./js/baseUrls.js"></script>
    <script>
            
        function addArr(){
        let title = $("#title").val();
        let abstract = $("#abstract").val();
        let content = $("#content").val();
        let classify = $("#classify").val();
        let autor = $("#autor").val();
        let obj={title,abstract,content,classify,autor}
            $.post("http://localhost:3000/blogs", obj, function (res) {
                    alert("增加成功！")
                    window.location.href = "./index.html"
                })

        }

        function cancel(){
            location.href="./index.html"
        }
    </script>

</body>

</html>